<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\controller;

/**
 * 前端首页控制器
 */
class Index extends IndexBase
{
    
    // 首页
    public function index($cid = 0)
    {
        //!empty作用:  该函数用于检查一个变量是否为空
        $where = [];
        
        !empty((int)$cid) && $where['a.category_id'] = $cid;
        
        $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
        
        $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
       
        return $this->fetch('index');
		
    }
    
    // 详情
    public function details($id = 0)
    {
        
        $where = [];
        
        !empty((int)$id) && $where['a.id'] = $id;
        
        $data = $this->logicArticle->getArticleInfo($where);
        
        $this->assign('article_info', $data);
        
        $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
         var_dump($this) ;	
        return $this->fetch('details');
    }
    // 首页2
  //   public function indexs($cid = 0)
  //   {
        
  //       $where = [];
        
  //       !empty((int)$cid) && $where['a.category_id'] = $cid;
        
  //       $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
        
  //       $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
        
  //       return $this->fetch('indexs');
		
  //   }
  //产品介绍
  public function product($cid = 0)
  {
      
      $where = [];
      
      !empty((int)$cid) && $where['a.category_id'] = $cid;
      
      $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
      
      $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
      
      return $this->fetch('product');
  	
  }
  //支持与服务
  public function service($cid = 0)
  {
      
      $where = [];
      
      !empty((int)$cid) && $where['a.category_id'] = $cid;
      
      $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
      
      $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
      
      return $this->fetch('service');
  	
  }
  //留言板
  public function message($cid = 0)
  {
      
      $where = [];
      
      !empty((int)$cid) && $where['a.category_id'] = $cid;
      
      $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
      
      $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
      
      return $this->fetch('message');
  	
  }
  //关于我们
  public function about($cid = 0)
  {
      
      $where = [];
      
      !empty((int)$cid) && $where['a.category_id'] = $cid;
      
      $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
      
      $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
      
      return $this->fetch('about');
  	
  }
  //登录/注册
  public function login($cid = 0)
  {
      
      $where = [];
      
      !empty((int)$cid) && $where['a.category_id'] = $cid;
      
      $this->assign('article_list', $this->logicArticle->getArticleList($where, 'a.*,m.nickname,c.name as category_name', 'a.create_time desc'));
      
      $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
      
      return $this->fetch('login');
  	
  }
}
